<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>赎回申请</title>
<jsp:include page="../../import.jsp" flush="true" />
<jsp:include page="../assParking/assParkCommon.jsp" flush="true" /><!-- 时间格式转换 -->
<style type="text/css">
 .overHide{height: 0; overflow: hidden;}
</style>
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<div>
			<div id="pageInTab" class="pageInTab">
				<!-- 页签1：赎回申请 -->
				<div tabid="tabA" title="赎回申请" lselected="true">
					<form id="redeemCar_view">
						<div class="fieldset1 tabel_col clearFix">
							<div class="fieldBox col_33">
								<div class="label">申请人</div>
				                <div class="field">
				                    <span id="applyNm" name="applyNm">&nbsp;</span>
				                </div>
							</div>
				            <div class="fieldBox col_33">
								<div class="label">申请时间</div>
								<div class="field">
									<span id="applyDt" name="applyDt">&nbsp;</span>
								</div>
							</div>
				            <div class="fieldBox col_33">
								<div class="label">拖车标记</div>
								<div class="field">
									<span id="backedFlagCd" name="backedFlagCd">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">赎回方式</div>
								<div class="field">
									<select name="redeemTypeCd" id="redeemTypeCd" ligerui="width: 160">
										<option value="" seleted>请选择</option>
										<c:forEach items="${redeemTypeList }" var="redeem">
											<option value="${redeem.key }">${redeem.value }</option>
										</c:forEach>
									</select>
								</div>
							</div>
				            <div class="fieldBox col_33 edit_fqr">
								<div class="label">赎回人姓名</div>
								<div class="field">
									<input type="text" id="cstNm" name="cstNm" class="ui-textbox" ligerui="width: 160" value="" readonly>
								</div>
							</div>
				            <div class="fieldBox col_33 show_fqr">
								<div class="label">赎回人姓名</div>
								<div class="field">
									<span id="cstNm_1" name="cstNm_1">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33 edit_fqr">
								<div class="label">赎回地点</div>
								<div class="field">
									<input type="text" id="redeemAddr" name="redeemAddr" class="ui-textbox" ligerui="width: 160" value="">
								</div>
							</div>
							<div class="fieldBox col_33 show_fqr">
								<div class="label">赎回地点</div>
								<div class="field">
									<span id="redeemAddr_1" name="redeemAddr_1">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33 edit_fqr">
								<div class="label">预计赎回时间</div>
								<div class="field">
									<input type="text" id="redeemTm" name="redeemTm" class="ui-datepicker" ligerui="width: 160" value="">
								</div>
							</div>
							<div class="fieldBox col_33 show_fqr">
								<div class="label">预计赎回时间</div>
								<div class="field">
									<span id="redeemTm_1" name="redeemTm_1">&nbsp;</span>
								</div>
							</div>
				            <div class="fieldBox col_33">
								<div class="label">GPS是否在线</div>
								<div class="field">
									<select name="isOnline" id="isOnline" ligerui="width: 160" onchange="showOrEdit()">
										<option value="" selected>请选择</option>
										<option value="1">是</option>
										<option value="0">否</option>
									</select>
								</div>
							</div>
							<div class="fieldBox col_33 edit_fxbzj">
								<div class="label">风险保证金1(元)</div>
								<div class="field">
									<input name="depositPct" id="depositPct" value="" type="text" class="ui-textbox" ligerui="width: 50" onchange="planRedeemMargin()">%
									<select name="amtTypeCd" id="amtTypeCd" ligerui="width: 80">
										<!-- 1：合同额    2：融资额 -->
										<c:forEach items="${amtTypeCdList}" var="item">
											<c:if test="${item.code !='3'}">  
												<option value="${item.code }" >${item.codeNm }</option>
											</c:if>
										</c:forEach>
									</select>
									<input name="depositAmt" id="depositAmt" value="" type="text" class="ui-textbox" ligerui="width: 50" onchange="planRedeemMarginPercent()">
									<input name="contAmt" id="contAmt" value="" type="hidden" class="ui-textbox" ligerui="width: 50">
									<input name="actLsAmt" id="actLsAmt" value="" type="hidden" class="ui-textbox" ligerui="width: 50">
									<input name="depositBaseAmt" id="depositBaseAmt" value="" type="hidden" class="ui-textbox" ligerui="width: 50">
								</div>
							</div>
							<div class="fieldBox col_33 show_fxbzj">
								<div class="label">风险保证金1(元)</div>
								<div class="field">
									<span id="depositAmt_1" name="depositAmt_1">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33 edit_cwhs">
								<div class="label">赎回逾期租金(元)</div>
								<div class="field">
									<input type="text" id="overdueAmt" name="overdueAmt" class="ui-textbox" ligerui="width: 160" value="" onchange="planRedeemMoney()">
								</div>
							</div>
							<div class="fieldBox col_33 show_cwhs">
								<div class="label">赎回逾期租金(元)</div>
								<div class="field">
									<span id="overdueAmt_1" name="overdueAmt_1">&nbsp;</span>
								</div>
							</div>
				            <div class="fieldBox col_33 edit_cwhs">
								<div class="label">赎回罚息(元)</div>
								<div class="field">
									<input type="text" id="interestAmt" name="interestAmt" class="ui-textbox" ligerui="width: 160" value="" onchange="planRedeemMoney()">
								</div>
							</div>
				            <div class="fieldBox col_33 show_cwhs">
								<div class="label">赎回罚息(元)</div>
								<div class="field">
									<span id="interestAmt_1" name="interestAmt_1">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33 edit_cwhs">
								<div class="label">赎回金额(元)</div>
								<div class="field">
									<input type="text" id="redeemAmt" name="redeemAmt" class="ui-textbox" ligerui="width: 160" value="">
								</div>
							</div>
							<div class="fieldBox col_33 show_cwhs">
								<div class="label">赎回金额(元)</div>
								<div class="field">
									<span id="redeemAmt_1" name="redeemAmt_1">&nbsp;</span>
								</div>
							</div>
                            <div class="fieldBox col_33 show_irr">
                                <div class="label">结清对客IRR(%)</div>
                                <div class="field">
                                    <span id="cstStlIrr" name="cstStlIrr">&nbsp;</span>
                                </div>
                            </div>
                            <div class="fieldBox col_33 show_stl_discount_amt_1">
                                <div class="label">结清优惠金额1(元)</div>
                                <div class="field">
                                    <span id="redeemStlDiscountAmt1" name="redeemStlDiscountAmt1">&nbsp;</span>
                                </div>
                            </div>
							<!-- 财务确认来款 -->
							<div class="fieldBox col_33 edit_cwqr">
								<div class="label">截止财务确认到账时赎回逾期租金(元)</div>
								<div class="field">
									<input type="text" id="actOverdueAmt" name="actOverdueAmt" class="ui-textbox" ligerui="width: 160" value="" onchange="planRedeemMoney()">
								</div>
							</div>
							<div class="fieldBox col_33 show_cwqr">
								<div class="label">截止财务确认到账时赎回逾期租金(元)</div>
								<div class="field">
									<span id="actOverdueAmt_1" name="actOverdueAmt_1">&nbsp;</span>
								</div>
							</div>
				            <div class="fieldBox col_33 edit_cwqr">
								<div class="label">截止财务确认到账时赎回罚息(元)</div>
								<div class="field">
									<input type="text" id="actInterestAmt" name="actInterestAmt" class="ui-textbox" ligerui="width: 160" value="" onchange="planRedeemMoney()">
								</div>
							</div>
				            <div class="fieldBox col_33 show_cwqr">
								<div class="label">截止财务确认到账时赎回罚息(元)</div>
								<div class="field">
									<span id="actInterestAmt_1" name="actInterestAmt_1">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33 edit_cwqr">
								<div class="label">截止财务确认到账时赎回金额(元)</div>
								<div class="field">
									<input type="text" id="actRedeemAmt" name="actRedeemAmt" class="ui-textbox" ligerui="width: 160" value="">
								</div>
							</div>
							<div class="fieldBox col_33 show_cwqr">
								<div class="label">截止财务确认到账时赎回金额(元)</div>
								<div class="field">
									<span id="actRedeemAmt_1" name="actRedeemAmt_1">&nbsp;</span>
								</div>
							</div>
							<!-- 实际支付拖车费用-只做显示不保存到赎回表里 -->
				            <div class="fieldBox col_33 edit_cwhs">
								<div class="label">实际付款金额(元)</div>
								<div class="field">
									<input type="text" id="actPayBackAmt" name="actPayBackAmt" class="ui-textbox" ligerui="width: 160" value="" readonly>
								</div>
							</div>
				            <div class="fieldBox col_33 show_cwhs">
								<div class="label">实际付款金额(元)</div>
								<div class="field">
									<span id="actPayBackAmt_1" name="actPayBackAmt_1">&nbsp;</span>
								</div>
							</div>
                            <!-- 应收款金额初始值：拖车审批流程中的保底价 -->
                            <div class="fieldBox col_33 edit_cwhs_ysk">
                                <div class="label">应收款金额(元)</div>
                                <div class="field">
                                    <input type="text" id="receivableAmt" name="receivableAmt" class="ui-textbox" ligerui="width: 160" value="" readonly>
                                </div>
                            </div>
                            <div class="fieldBox col_33 edit_cwqr hide_abc">
                                <div class="label">实际到账金额(元)</div>
                                <div class="field">
                                    <input name="actPayAmt" id="actPayAmt" value="" type="text" class="ui-textbox" validate="">
                                </div>
                            </div>
                            <div class="fieldBox col_33 show_cwqr">
                                <div class="label">实际到账金额(元)</div>
                                <div class="field">
                                    <span id="actPayAmt_1" name="actPayAmt_1">&nbsp;</span>
                                </div>
                            </div>
                            <div class="fieldBox col_33 edit_cwqr hide_abc">
                                <div class="label">实际到账时间</div>
                                <div class="field">
                                    <input name="actPayTm" id="actPayTm" value="" type="text" class="ui-datepicker" validate="">
                                </div>
                            </div>
                            <div class="fieldBox col_33 show_cwqr">
                                <div class="label">实际到账时间</div>
                                <div class="field">
                                    <span id="actPayTm_1" name="actPayTm_1">&nbsp;</span>
                                </div>
                            </div>
                            <div class="fieldBox col_33">
                                <div class="label">赎回方</div>
                                <div class="field">
                                    <select name="redeemWayCd" id="redeemWayCd" >
                                        <option value=" " selected="selected" >--请选择--</option>
                                        <c:forEach items="${redeemWayList}" var="redeemWay">
                                            <option value="${redeemWay.key}">${redeemWay.value}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                            </div>
							<!-- 赎回信息 -->
				            <div class="fieldBox col_100 edit_shsm">
								<div class="label">赎回说明</div>
								<div class="field">
									<textarea name="redeemDesc" id="redeemDesc" rows="3" class="l-textarea" style="width:98%" value="" ></textarea>
								</div>
							</div>
				            <div class="fieldBox col_100 show_shsm">
								<div class="label">赎回说明</div>
								<div class="field">
									<span id="redeemDesc_1" name="redeemDesc_1">&nbsp;</span>
								</div>
							</div>
                            <!-- 上传附件 -->
                            <div class="fieldBox col_100">
                                <div class="label">附件上传</div>
                                <div class="fieldset1 tabel_col clearFix">
                                    <div class="sqPanel_body">
                                        <div id="redeemFileGrid" class="sq-grid"></div>
                                    </div>
                                </div>
                            </div>
                            <!-- 商助审核GPS的GPS信息 -->
                            <div class="caption gpsTitle Hide">
                                <span class="title">GPS信息</span>
                            </div>
                            <div class="fieldset1 tabel_col clearFix">
                                <div class="fieldBox col_50 Hide carNo">
                                    <div class="label">车牌号</div>
                                    <div class="field">
                                        <input type="text" id="carNo" name="carNo" class="ui-textbox" ligerui="width: 160" value="${vehNo}">
                                    </div>
                                </div>
                                <div class="fieldBox col_50 Hide vin">
                                    <div class="label">车架号</div>
                                    <div class="field">
                                        <input type="text" id="vin" name="vin" class="ui-textbox" ligerui="width: 160" value="${vin}">
                                    </div>
                                </div>
                                <div class="fieldBox col_33 Hide gps1">
                                    <div class="label">GPS卡号1</div>
                                    <div class="field">
                                        <input type="text" id="gps1" name="gps1" class="ui-textbox" ligerui="width: 160" value="${gps1}">
                                    </div>
                                </div>
                                <div class="fieldBox col_33 Hide gps2">
                                    <div class="label">GPS卡号2</div>
                                    <div class="field">
                                        <input type="text" id="gps2" name="gps2" class="ui-textbox" ligerui="width: 160" value="${gps2}">
                                    </div>
                                </div>
                                <div class="fieldBox col_33 Hide gps3">
                                    <div class="label">GPS卡号3</div>
                                    <div class="field">
                                        <input type="text" id="gps3" name="gps3" class="ui-textbox" ligerui="width: 160" value="${gps3}">
                                    </div>
                                </div>
                                <div class="fieldBox col_50 Hide installer">
                                    <div class="label">安装人</div>
                                    <div class="field">
                                        <input type="text" id="installer" name="installer" class="ui-textbox" ligerui="width: 160" value="${installer}">
                                    </div>
                                </div>
                                <div class="fieldBox col_50 Hide installDt">
                                    <div class="label">安装时间</div>
                                    <div class="field">
                                        <input name="installDt" id="installDt" type="text" class="ui-datepicker" value="<fmt:formatDate value="${installDt}" pattern="yyyy-MM-dd"/>">
                                    </div>
                                </div>
                                <div class="fieldBox col_100 edit_shfj_gps Hide">
                                    <div class="label">资料上传</div>
                                    <div class="field">
                                        <div id="fileUpload4" class="upfileBoxs"></div>
                                        <span class="sq-button sq-button-hasicon" id="btnUpload4" onclick="ajaxFileUploadImg('uploads4', 4)">
                                            <i class="sqBtnIco_9"></i>上传
                                        </span>
                                    </div>
                                </div>
                                <div class="fieldBox col_100 Hide gpsRem">
                                    <div class="label">备注</div>
                                    <div class="field">
                                        <textarea name="gpsRem" id="gpsRem" rows="3" class="l-textarea" style="width:98%">${gpsRem}</textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="fieldBox col_100 showGpsFiles">
                                <div style="width: 98%; margin-left: 1%;">
                                    <div id="ligergrid_file4" class="sq-grid"></div>
                                </div>
                            </div>

							<div class="edit_bsxx gpsBtn" style="text-align: center;line-height: 2.3em;">
								<span id="updateBscInfoBtn" class="sq-button sq-button-round" onclick="saveRedeemCar('1')">保存</span>
							</div>
							<!-- 付款信息 -->
							<div class="caption">
								<span class="title">付款方</span>
							</div>
							<div class="fieldBox col_100">
								<div class="sqPanel">
									<div id="detailGrid">
										<div style="text-align: right;line-height: 2.3em;" class="edit_gps_st">
											<c:if test="${flag == '5' }">
												<span id="editPayInfo" class="sq-button sq-button-round" onclick="editPayInfo('')">添加</span>
											</c:if>
										</div>
										<!-- 实际到账信息列表显示块 -->
										<div id="ligergrid2" class="sq-grid"></div>
									</div>
								</div>
							</div>
							
							<!-- 来款凭证上传附件 -->
							<c:if test="${flag == '5' }">
							<div class="fieldBox col_100">
								<div class="label">来款凭证上传</div>
								<div class="field">
									<div id="fileUpload2" class="upfileBoxs"></div>
									<span class="sq-button sq-button-hasicon" id="btnUpload2" onclick="ajaxFileUploadImg('uploads2',2)">
										<i class="sqBtnIco_9"></i>上传
									</span>
								</div>
							</div>
							</c:if>
							<!-- 来款凭证附件显示 -->
							<div class="fieldBox col_100">
								<div style="width: 98%; margin-left: 1%;">
									<div id="ligergrid_file2" class="sq-grid"></div>
								</div>
							</div>
							<c:if test="${flag == '5' }">
							<div class="btnsBox">
							  <span id="savePayInfoFileBtn" class="sq-button sq-button-round" onclick="javascript:saveFile('lkpz_sh')">保存</span>
							</div>
							</c:if>
							
							<!-- 收款信息 -->
							<div class="caption">
								<span class="title">收款方</span>
							</div>
							<div class="fieldBox col_33 edit_tzdk">
								<div class="label">收款银行</div>
								<div class="field">
									<input name="payeeBankNm" id="payeeBankNm" value="" type="text" class="ui-textbox" validate="">
								</div>
							</div>
							<div class="fieldBox col_33 show_tzdk">
								<div class="label">收款银行</div>
								<div class="field">
									<span id="payeeBankNm_1" name="payeeBankNm_1">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33 edit_tzdk">
								<div class="label">收款账号</div>
								<div class="field">
									<input name="payeeAccNo" id="payeeAccNo" value="" type="text" class="ui-textbox" validate="">
								</div>
							</div>
							<div class="fieldBox col_33 show_tzdk">
								<div class="label">收款账号</div>
								<div class="field">
									<span id="payeeAccNo_1" name="payeeAccNo_1">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33 edit_tzdk">
								<div class="label">收款方名称</div>
								<div class="field">
									<input name="payeeAccNm" id="payeeAccNm" value="" type="text" class="ui-textbox" validate="">
								</div>
							</div>
							<div class="fieldBox col_33 show_tzdk">
								<div class="label">收款方名称</div>
								<div class="field">
									<span id="payeeAccNm_1" name="payeeAccNm_1">&nbsp;</span>
								</div>
							</div>
							<!-- 提车人信息 -->
							<div class="caption">
								<span class="title">提车人信息</span>
							</div>
							<div class="fieldBox col_33 edit_tcr">
								<div class="label">提车人姓名</div>
								<div class="field">
									<input name="pickCarNm" id="pickCarNm" value="" type="text" class="ui-textbox" validate="{required:false}">
								</div>
							</div>
							<div class="fieldBox col_33 show_tcr">
								<div class="label">提车人姓名</div>
								<div class="field">
									<span id="pickCarNm_1" name="pickCarNm_1">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33 edit_tcr">
								<div class="label">提车人联系电话</div>
								<div class="field">
									<input name="pickCarTel" id="pickCarTel" value="" type="text" class="ui-textbox" validate="{required:false}">
								</div>
							</div>
							<div class="fieldBox col_33 show_tcr">
								<div class="label">提车人联系电话</div>
								<div class="field">
									<span id="pickCarTel_1" name="pickCarTel_1">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33 edit_tcr">
								<div class="label">提车人身份证号</div>
								<div class="field">
									<input name="pickCarCd" id="pickCarCd" value="" type="text" class="ui-textbox" validate="{required:false}">
								</div>
							</div>
							<div class="fieldBox col_33 show_tcr">
								<div class="label">提车人身份证号</div>
								<div class="field">
									<span id="pickCarCd_1" name="pickCarCd_1">&nbsp;</span>
								</div>
							</div>
							<!-- 上传提车人附件 -->
							<div class="fieldBox col_100 edit_tcr">
								<div class="label">附件上传</div>
								<div class="field">
									<div id="fileUpload3" class="upfileBoxs"></div>
									<span class="sq-button sq-button-hasicon" id="btnUpload3" onclick="ajaxFileUploadImg('uploads3',3)">
										<i class="sqBtnIco_9"></i>上传
									</span>
								</div>
							</div>
                            <jsp:include page="../assCommFilesUpload.jsp" flush="true" >
                                <jsp:param name="filePath" value="ass"/>
                            </jsp:include>
                            <jsp:include page="../assCommFilesList.jsp" flush="true" ></jsp:include>
							<!-- 附件显示 -->
							<div class="fieldBox col_100">
								<div style="width: 98%; margin-left: 1%;">
									<div id="ligergrid_file3" class="sq-grid"></div>
								</div>
							</div>
							<!-- 隐藏支付表主键、支付表号 -->
			                <div class="fieldBox col_100" style="display:none;">
			                    <div class="field">
			                         <input name="tcMasterId" id="tcMasterId" type="text" class="ui-textbox" value="${tcMasterId}">
			                         <input name="tcDetailId" id="tcDetailId" type="text" class="ui-textbox" value="${tcDetailId}">
			                         <input name="paySchId" id="paySchId" type="text" class="ui-textbox" value="${paySchId}">
	                         		 <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="">
			                         <input name="cstId" id="cstId" type="text" class="ui-textbox" value="${cstId}">
			                         <input name="buOrgCd" id="buOrgCd" type="text" class="ui-textbox" value="${buOrgCd}">
			                         <input name="redeem_Id" id="redeem_Id" type="text" class="ui-textbox" value="${redeem_Id}">
			                         <input name="processId" id="processId" type="text" class="ui-textbox" value="${processId}">
			                         <input name="taskDefKey" id="taskDefKey" type="text" class="ui-textbox" value="${taskDefKey}">
	                         		 <input name="flag" id="flag" type="text" class="ui-textbox" value="${flag}">
	                         		 <input name="assDealRecAmt_id" id="assDealRecAmt_id" type="text" class="ui-textbox" value="${assDealRecAmt_id }">
			                         <!-- 上传文件使用：系统时间和当前登录人姓名 -->
			                         <input name="sysDate" id="sysDate" type="text" class="ui-textbox" value="${sysDate }">
			                         <input name="loginUsrNm" id="loginUsrNm" type="text" class="ui-textbox" value="${loginUsrNm }">
			                    </div>
			                </div>
			                
			                <!-- 核销列表信息 start -->
							<div id="capFund1" class="caption Hide">
								<span class="title">核销列表</span>
							</div>
							<div class="fieldBox col_100 capFund overHide">
								<div class="sqPanel capFund overHide">
									<div id="detailGrid">
										<div style="text-align: right;line-height: 2.3em;" class="edit_gps_st">
												<span  class="sq-button sq-button-round" onclick="revertFund()">申请冲红</span>
										</div>
										<!-- 核销列表显示块 -->
										<div id="ligergrid3" class="sq-grid"></div>
									</div>
								</div>
							</div>
						</div>
						<div class="btnsBox saveBtn">
							<span id="saveRedeemCarBtn" class="sq-button sq-button-round" onclick="saveRedeemCar('4')">保存基本信息</span>
						</div>
					</form>

					<%--绑定资金--%>
					<c:if test="${bizTyp=='3' }">
						<jsp:include page="../../capital/capFund/capFundAddBind.jsp" flush="true"></jsp:include>
					</c:if>

				</div>
				<!-- 页签2：拖车单信息 -->
				<div tabid="tabB" title="拖车单信息" id="tabBId" style="dis">
					<iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
				</div>
			</div>
		</div>
	</div>

    <script>
	    var pageInApp={
				flag:false //tab页验证关闭
		};//to下一级子窗口 接口
		var pageInTab=null;//页签
		var loadedTabs=[];//页签
		//是否隐藏：付款方的操作
		var isDetail = '${isDetail}';
		var isShow_flag = (isDetail == '0');
		var l_hidden = isShow_flag ? "l-hidden" : "";

		var redeemId = "${redeem_Id}";

	    $(function() {
	        var flag = $("#flag").val();
	        var redeemTypCd = '${redeemTypCd}';
	    	initForm();//初始化表单
	        initTab();//初始化页签
	        initData();//初始化数据
            // 只有赎回结清且流程节点在商助审核GPS且以后的节点才显示
            if ('2' == redeemTypCd) {
                if ('7' == flag || '8' == flag || '9' == flag || '11' == flag || '12' == flag) {
                    loadFilesLiger("tcsh_gps", "4", $("#redeem_Id").val());//加载商助审核gps文件列表信息
                }
            }
	    	// loadFilesLiger("tcsh", 1, $("#redeem_Id").val());//加载赎回申请文件列表信息
	    	loadFilesLiger("shtcr", 3, $("#redeem_Id").val());//加载赎回提车人文件列表信息
	    	loadFilesLiger("lkpz_sh", 2, $("#redeem_Id").val());//加载赎回来款凭证文件列表信息
			//设置提车人信息是否为必填
			var formSet1=liger.get("redeemCar_view");
	        if('${flag}' == '7'){//呈报人补充提车人信息
				//设置《必选》验证规则
                formSet1.setFieldValidate("pickCarNm", {required: true});
                formSet1.setFieldValidate("pickCarTel", {required: true});
                formSet1.setFieldValidate("pickCarCd", {required: true});
	        }else{
	        	//取消《必选》验证规则
                formSet1.setFieldValidate("pickCarNm", {required: false});
                formSet1.setFieldValidate("pickCarTel", {required: false});
                formSet1.setFieldValidate("pickCarCd", {required: false});
	        }
            initRedeemFileGrid(redeemTypCd);
	    });

        var redeemFileGrid = null;

        // 维护过户方案资料Grid
        function initRedeemFileGrid(redeemTypCd) {
            redeemFileGrid = $("#redeemFileGrid").ligerGrid({
                url: '<%=path%>/ass/assDealRedeem/initRedeemFileGrid.do?id=' + redeemId + '&cfgCd=ASS009' + '&redeemTypCd=' + redeemTypCd,
                method: 'get',
                columns: [
                    {display: '资料名称', name: 'datNm', align: 'center', minWidth: 100, enabledSort: false},
                    {
                        display: '上传文件名称', name: 'fileNm', minWidth: 100, enabledSort: false,
                        render: function (rowdata, rowindex, value) {
                            if (value) {
                                var h;
                                h = '<a href="javascript:downloadFileByUrl(';
                                h += "'" + rowdata.filePath + "'";
                                h += ",'" + rowdata.fileNm + "'";
                                h += ')">' + rowdata.fileNm + '</a>'
                                return h;
                            }
                        }
                    },
                    {
                        display: '上传时间',
                        name: 'crtTm',
                        align: 'center',
                        width: 150,
                        enabledSort: false,
                        render: renderDate
                    }
                ],
                root: 'rows',
                hideLoadButton: true,
                width: '100%',
                height: '200px',
                isScroll: false,
                rownumbers: true,  //显示序号
                checkbox: false,
                allowUnSelectRow: true,
                alternatingRow: false,
                frozen: false,
                usePager: false,
                onAfterShowData: function () {
                    $('#redeemFileGrid').rowspan('datNm');
                    $('#redeemFileGrid').rowspan('operate');
                },
            });
        }

        //下载文件方法
        function downloadFileByUrl(_url,_name){
            if(SQ.regs.img.test(_name)){
                SQ.imgPreview(_url, true);
            }else{
                window.open(_url);
            }
        }

        // 上传文件a标签链接到input标签上
        function uploadFile(cfgCd, cfgDtlCd) {
            document.getElementById("uploadInput_" + cfgCd + "_" + cfgDtlCd).click();
        }

        /**
         * 上传文件
         * @param e
         * @param cfgCd
         * @param cfgDtlCd
         * @param orgCd
         */
        function onChangefile_multi(e, cfgCd, cfgDtlCd, orgCd) {
            var wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            var filePath = "";
            filePath = "assDealFile";
            $.ajaxFileUpload({
                url: '<%=path%>/system/sysulfilesrec/upload.do',
                secureuri: false,
                fileElementId: e.target.id,  //这里不在是以前的id了，要写成数组的形式！
                dataType: 'json',
                data: {filePath: filePath},
                success: function (msg) {
                    if (msg.success == 1) {
                        $.ajax({
                            type: 'post',
                            dataType: 'json',
                            data: {
                                'fileParams': JSON.stringify(msg.data),
                                'id': sellId,
                                'cfgCd': cfgCd,
                                'cfgDtlCd': cfgDtlCd,
                                'orgCd': orgCd
                            },
                            url: '<%=path%>/ass/assDealRedeem/uploadRedeemFile.do',
                            success: function (msg) {
                                if (msg.success == 1) {
                                    redeemFileGrid.reload();
                                } else {
                                    $.ligerDialog.SQalert({content: "资料上传超时", SQ_type: "error"});
                                }
                                $.ligerDialog.hide();
                            }
                        });
                    } else {
                        wait_dialog.close();
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        };

        // 格式化时间
        function renderDate(rowdata, index, value) {
            var dateStr = "";
            if (null != value) {
                var date = new Date(value);
                dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
            }
            return dateStr;
        }
	    
	  	//初始化表单
		function initForm(){
	    	$("#redeemCar_view").ligerForm({
				validate: true
			});
			$("#redeemCar_view").check_ligerFormEditor();//重新刷新页面动态字段
			//初始化赎回保证金计算基数类型-change方法
			liger.get('amtTypeCd').bind('changeValue', function () {
				var type = this.getValue();
				var contAmt = $("#contAmt").val();
				var actLsAmt = $("#actLsAmt").val();
				if(type == "1"){//合同额
					$("#depositBaseAmt").val(contAmt);
				}else{//融资额
					$("#depositBaseAmt").val(actLsAmt);
				}
				//planRedeemMargin();//计算赎回保证金
			});
		};
		
	  	//初始化Tab页签
		function initTab(){
			var crflag = "";
			var flag = $("#flag").val();
			if(flag == "8"){//资产管理员出库登记
				crflag = "out";//出库
			}else{
				crflag = "detail";//查看
			}
			pageInTab = $("#pageInTab").ligerTab({
				height: 'auto',
				contextmenu: false,
				minIframeHeight: GET_minIframeHeight(),
				onAfterSelectTabItem: function(tabid) {
					//获取拖车主表ID和明细表ID供其它页面使用
					var tcMasterId = $("#tcMasterId").val();
					var tcDetailId = $("#tcDetailId").val();
					var busid= $("#redeem_Id").val();
					var processId= $("#processId").val();
					var taskDefKey= $("#taskDefKey").val();
					if(tabid!="tabA"){
						if(!tcDetailId || !tcMasterId){
							$.ligerDialog.SQalert({content: "抱歉信息不存在！", SQ_type: "warning"});
							return false; //验证不通过，不执行以下代码
						}
					}
					switch (tabid){
						case "tabB":	
							if(flag == "6"||flag == "2"||flag == "12"){
								pageInTab.setTabItemSrc(tabid, "<%=path%>/ass/assTrailCarM/toInfoViewPage.do?tcMasterId="+tcMasterId+"&tcDetailId="+tcDetailId+"&crflag="+crflag+"&busid="+busid+"&processId="+processId+"&taskDefKey="+taskDefKey);
								break;
							}else{
								pageInTab.setTabItemSrc(tabid, "<%=path%>/ass/assTrailCarM/toInfoViewPage.do?tcMasterId="+tcMasterId+"&tcDetailId="+tcDetailId+"&crflag="+crflag);	
								break;
							}
					}
					SetIframe_height();
				}
			});
			//设置页签
			$.extend(true, pageInApp, {
				pageInTab: pageInTab
			});
		};
		
		//初始化数据
	    function initData(){
	    	var redeemId = $("#redeem_Id").val();
	    	if(!redeemId){
	    		$.ligerDialog.SQalert({content: "拖车赎回主表ID为空,无法查询相关信息！",SQ_type: "error"});
	    		return;
	    	}
	    	//var wait_dialog= $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_LOADING,SQ_type: "waitting"});
	    	//加载赎回主表信息
	    	var _url = '<%=path%>/ass/assTrailCarD/getRedeemInfoById.do';
	    	$.ajax({
	    		type: 'get',
	    		dataType:'json',
	    		data:{redeemId:redeemId},
	    		url: _url,
	    		success:function(msg){
	    			 //wait_dialog.close();
	    			 if(msg.success == 1){
	    				 if(null != msg.data){
	    				 	setData(msg.data);//设置数据
	    				 }
	    			 }else{
	    				 $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
	    			 }
	    		}
	    	});
	    }
		//设置页面数据
	    function setData(data){
	    	var form = liger.get("redeemCar_view");//加载表单
			//设置合同额和融资额
			$("#contAmt").val(data.contAmt / 100);
			$("#actLsAmt").val(data.actLsAmt / 100);
			$("#depositBaseAmt").val(data.depositBaseAmt / 100);
			form.setData({
				redeemTypeCd: data.redeemTypeCd, //赎回方式
				cstNm: data.cstNm,
				redeemAddr: data.redeemAddr,
				redeemTm: renderDate1(data.redeemTm),
				isOnline: data.isOnline, //GPS是否在线
				depositPct: data.depositPct,
				amtTypeCd: data.amtTypeCd,
				depositAmt: data.depositAmt / 100,
				overdueAmt: data.overdueAmt / 100,
				interestAmt: data.interestAmt / 100,
				redeemAmt: data.redeemAmt / 100,
				actOverdueAmt: data.actOverdueAmt / 100,//实际赎回逾期租金
				actInterestAmt: data.actInterestAmt / 100,//实际赎回罚息
				actRedeemAmt: data.actRedeemAmt / 100,//实际赎回金额
				actPayBackAmt: data.actPayBackAmt / 100, //实际支付拖车费用
				redeemDesc: data.redeemDesc,
				actPayAmt: data.actPayAmt / 100,
				actPayTm: renderDate1(data.actPayTm),
				payeeAccNm: data.payeeAccNm,
				payeeBankNm: data.payeeBankNm,
				payeeAccNo: data.payeeAccNo,
				pickCarNm: data.pickCarNm,
				pickCarTel: data.pickCarTel,
				pickCarCd: data.pickCarCd
	    	});
			//加载日期插件
			$("#redeemTm").trigger("change");
			$("#actPayTm").trigger("change");
			//显示基本信息
			$("#applyNm").html(data.crtUsrRlNm);
 	    	$("#applyDt").html(renderDate1(data.crtTm));
			$("#backedFlagCd").html(data.backedFlagCd);
			$("#cstNm_1").html(data.cstNm);
			$("#redeemAddr_1").html(data.redeemAddr);
			$("#redeemTm_1").html(renderDate1(data.redeemTm));
			$("#overdueAmt_1").html(data.overdueAmt / 100);
			$("#interestAmt_1").html(data.interestAmt / 100);
			$("#redeemAmt_1").html(data.redeemAmt / 100);
			$("#actOverdueAmt_1").html(data.actOverdueAmt / 100);//实际赎回逾期租金
			$("#actInterestAmt_1").html(data.actInterestAmt / 100);//实际赎回罚息
			$("#actRedeemAmt_1").html(data.actRedeemAmt / 100);//实际赎回金额
			$("#actPayBackAmt_1").html(data.actPayBackAmt / 100);
			$("#redeemDesc_1").html(data.redeemDesc);
			$("#actPayAmt_1").html(data.actPayAmt / 100);
 	    	$("#actPayTm_1").html(renderDate1(data.actPayTm));
			$("#payeeAccNm_1").html(data.payeeAccNm);
			$("#payeeBankNm_1").html(data.payeeBankNm);
			$("#payeeAccNo_1").html(data.payeeAccNo);
			$("#pickCarNm_1").html(data.pickCarNm);
			$("#pickCarTel_1").html(data.pickCarTel);
			$("#pickCarCd_1").html( data.pickCarCd);
            $("#cstStlIrr").html( data.cstStlIrr * 100);
            $("#redeemStlDiscountAmt1").html( data.discountAmt / 100);
 	    	//设置拖车信息主键值
 	    	$("#tcMasterId").val(data.masterId);
			$("#tcDetailId").val(data.detailId);
 	    	showDepositAmt(data);//显示风险保证金和应收款金额
			//planRedeemMoney();//计算赎回金额
 	    	initPkData(data.overdueAmt,data.actRedeemAmt);//初始化关键信息
            liger.get("redeemWayCd").selectValue(data.redeemWayCd);
            liger.get("redeemWayCd").setDisabled(true);
 	    	if(data.redeemTypeCd == '1'){//赎回结清、财务确认到账节点
 	    		if($("#flag").val() == '6'){//财务确认到账节点
 	    			$("#redeemCar_view").find(".capFund").each(function (){
 		        		$(this).removeClass('overHide');
 		        	});
 	    			$("#capFund1").removeClass('Hide');
 	    		}else{
 	    			 $("#trailCar_view").find(".capFund").each(function (){
 		        		$(this).addClass('overHide');
 		        	}); 
 	    			$("#capFund1").addClass('Hide');
 	    		}
 	    	}else{
    			$("#redeemCar_view").find(".capFund").each(function (){
	        		$(this).addClass('overHide');
	        	});
    			$("#capFund1").addClass('Hide');
 	    	}
	    }
		
	  	//初始化数据
	    function initPkData(overdueAmt,actRedeemAmt){
	    	var id = $("#tcDetailId").val();
	    	if(!id){
	    		$.ligerDialog.SQalert({content: "拖车赎回主表ID为空,无法查询相关信息！",SQ_type: "error"});
	    		return;
	    	}
	    	//获取拖车明细信息
	    	var _url = '<%=path%>/ass/assTrailCarD/getById.do';
	    	$.ajax({
	    		type: 'get',
	    		dataType:'json',
	    		data:{id:id},
	    		url: _url,
	    		success:function(msg){
	    			 if(msg.success == 1){
	    				 if(null != msg.data){
	    				 	setPkData(msg.data,overdueAmt,actRedeemAmt);//设置数据
	    				 }
	    			 }else{
	    				 $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
	    			 }
	    		}
	    	});
	    }
	  	
	  	//设置页面数据
	    function setPkData(data,overdueAmt,actRedeemAmt){
	    	var form = liger.get("redeemCar_view");//加载表单
			form.setData({
				paySchId: data.paySchId,
				paySchNo: data.paySchNo,
				cstId: data.cstId,
				buOrgCd: data.buOrgCd
	    	});
	        showOrEdit();//显示还是编辑
	        var flag = $("#flag").val();
	        var redeemTypeCd = $("#redeemTypeCd").val();
	        if(redeemTypeCd == "2" && (flag == "2" || flag == "6")){//赎回转正常-财务核算赎回金额节点/财务确认来款节点
	        	initOverData(overdueAmt,actRedeemAmt);
	        }
	        //feeOutShow();//保证金转出
	  	}
		
	  	//初始化数据
	    function initOverData(overdueAmt,actRedeemAmt){
	    	var paySchId = $("#paySchId").val();
	    	if(!paySchId)return;
	    	
	    	var _url = '<%=path%>/ass/assTrailCarD/getTrailCarApplyInfo.do';
	    	$.ajax({
	    		type: 'get',
	    		dataType:'json',
	    		data:{enabledPaySchId:paySchId, dataFlag:"2"},
	    		url: _url,
	    		success:function(msg){
	    			 if(msg.success == 1 && null != msg.data){
	    				 setOverData(msg.data,overdueAmt,actRedeemAmt);//设置数据
	    			 }else{
	    				 $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
	    			 }
	    		}
	    	});
	    }
		
		//设置页面逾期数据
	    function setOverData(data,overdueAmt,actRedeemAmt){
	    	var form2 = liger.get("redeemCar_view");//加载表单
	    	if(!overdueAmt){//为空执行-财务核算
				form2.setData({
					overdueAmt: data[0].overdueAmt / 100, //逾期租金
					interestAmt: data[0].penaltyAmt / 100 //罚息
		    	});
	    	}
	    	if(!actRedeemAmt){//为空执行-财务确认
				form2.setData({
					actOverdueAmt: data[0].overdueAmt / 100, //逾期租金
					actInterestAmt: data[0].penaltyAmt / 100 //罚息
		    	});
	    	}
			//计算赎回金额
			planRedeemMoney();
	    }
	  	
		//显示风险保证金1(元)和应收款金额(元)
		function showDepositAmt(data){
			var base = "融资额";
 	    	var percent = "0";
 	    	var depositAmt = "0";
 	    	var depositAmt_1 = "";
 	    	if(data.amtTypeCd != null){
 	    		if(data.amtTypeCd == "2"){
 	    			base = "融资额";
 	    		}else if(data.amtTypeCd == "1"){
 	    			base = "合同额";
 	    		}
 	    	}
 	    	if(data.depositPct != null){
 	    		percent = data.depositPct;
 	    	}else{
 	    		var form = liger.get("redeemCar_view");//加载表单
 	    		form.setData({
 					depositPct: 0, 
 					depositAmt: 0 //默认值为0
 	    		});
 	    	}
 	    	if(data.depositAmt != null){
 	    		depositAmt = data.depositAmt / 100;
 	    	}
 	    	depositAmt_1 = "( " + percent + "% * " + base + " ) " + depositAmt;
 	    	$("#depositAmt_1").html(depositAmt_1);
 	    	//显示应收款金额(元)
 	    	if(data.receivableAmt != null){
 	    		$("#receivableAmt").val(data.receivableAmt / 100);
 	    		$("#receivableAmt_1").html(data.receivableAmt / 100);
 	    	}else{//初始值为拖车保底价
 	    		$("#receivableAmt").val(data.baseAmt / 100);
 	    		$("#receivableAmt_1").html(data.baseAmt / 100);
 	    	}
		}
		
		//保存文件
		function saveFile(type){
			var index = 1;//赎回申请附件
			var eflag = "tcsh";
			var flag = $("#flag").val();
			if(flag == "5" || flag == "7"){
				index = 3;//提车人附件
				eflag = "shtcr";
				if(type == 'lkpz_sh'){
					index = 2;//来款凭证附件
					eflag = "lkpz_sh";
				}
			}
			if ("11" == flag) {
			    // gps附件
			    index = 4;
                eflag = "tcsh_gps";
            }
			var docArray = JSON.stringify(getUploadResultParams(index));
	        var url = "<%=path%>/ass/assTrailCarD/uploadAttchment.do";
	        var redeemId = $("#redeem_Id").val();
        	if(null == docArray){
        		return false;
        	}else{
		        if(redeemId){//赎回主表ID不为空执行
			        //赋值附件
			        var data = {
						"docArray": docArray,
						"pkId": redeemId,
						"flag": eflag
					};
					//请求
			        AjaxUtils.ajaxPost(url, data, function(msg){
			        	if(msg.success == 1){
							 if(msg.data){
								 //刷新附件页面GRID方法和清空上传按钮
								 refreshUlFileRecList(index);
								 clearUploadResultParams(index);
							 }
							 if(type == 'lkpz_sh'){
									top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
							 }
						 }else{
							 UIUtils.alertError(msg.info);
						 }
			        }, true);
		        }else{
		        	$.ligerDialog.SQalert({content: "业务主键为空-不能保存文件！",SQ_type: "error"});
		        }
        	}
		}

		function validateGPS(gps) {
            var reg = /^[0-9]+.?[0-9]*$/;
            if (gps) {
                // 校验GPS卡号必须是纯数字
                if (!reg.test(gps) || gps.length != 15) {
                    $.ligerDialog.SQalert({content: "GPS卡号仅支持15位纯数字", SQ_type: "error"});
                    return false;
                }
            }
            return true;
        }

        //显示已上传但是未保存的文件列表
        function showFiles(data, index){
            var sysDate = $("#sysDate").val();
            var loginUsrNm = $("#loginUsrNm").val();
            var f_Grid = liger.get("ligergrid_file"+index);
            var uploadJOSN = data;
            for (var i=0; i< uploadJOSN.length; i++){
                //添加行-追加行
                f_Grid.addRow({fileNm: uploadJOSN[i].fileNm, crtUsrRlNm: loginUsrNm, crtTm: sysDate, doSthFlag: "1", ligerIndex: index,id:i});
            }
        }

        function addGps(msg, data) {
            if (msg.success == 2) {
                var map = eval(msg.data);
                if (map[data.gps1]) {
                    data["receiveName1"] = map[data.gps1].receiveName;
                    data["receiveRealName1"] = map[data.gps1].receiveRealName;
                    data["gpsDeviceType1"] = map[data.gps1].gpsDeviceType;
                } else if (map[data.gps2]) {
                    data["receiveName2"] = map[data.gps2].receiveName;
                    data["receiveRealName2"] = map[data.gps2].receiveRealName;
                    data["gpsDeviceType2"] = map[data.gps2].gpsDeviceType;
                } else if (map[data.gps3]) {
                    data["receiveName3"] = map[data.gps3].receiveName;
                    data["receiveRealName3"] = map[data.gps3].receiveRealName;
                    data["gpsDeviceType3"] = map[data.gps3].gpsDeviceType;
                }
            } else if (msg.success == 1 && msg.data) {
                data["receiveName1"] = msg.data.receiveName;
                data["receiveRealName1"] = msg.data.receiveRealName;
                data["gpsDeviceType1"] = msg.data.gpsDeviceType;

                data["receiveName2"] = msg.data.receiveName;
                data["receiveRealName2"] = msg.data.receiveRealName;
                data["gpsDeviceType2"] = msg.data.gpsDeviceType;

                data["receiveName3"] = msg.data.receiveName;
                data["receiveRealName3"] = msg.data.receiveRealName;
                data["gpsDeviceType3"] = msg.data.gpsDeviceType;
            }
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: data,
                url: '<%=path%>/ass/assTrailCarD/saveGPSInfoOfNewRules.do',
                success:function(msg) {
                    if (msg.success == 1) {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                    } else {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        }
		
		//保存处置请信息（处置信息主表）
		function saveRedeemCar(opFlag){
            var flag = $("#flag").val();
            // 赎回方式
            var redeemTypCd = $("#redeemTypeCd").val();
            if ("11" == flag) {
                // 保存GPS信息时的校验
                if ("1" == opFlag) {
                    // 校验当前页gps是否在线是否选择
                    var isOnline = $("#isOnline").val();
                    if ("" == isOnline || null == isOnline) {
                        top.$.ligerDialog.SQalert({content: "请选择GPS是否在线！", SQ_type: "error"});
                        return false; //验证不通过，不执行以下代码
                    }
                    // 赎回转正常&gps是否在线：否
                    if ("2" == redeemTypCd && "0" == isOnline) {
                        var gps1 = $("#gps1").val();
                        var gps2 = $("#gps2").val();
                        var gps3 = $("#gps3").val();
                        if ((!gps1 && !gps2 && !gps3) || (gps1 == 0 && gps2 == 0 && gps3 == 0)) {
                            top.$.ligerDialog.SQalert({content: "GPS卡号不能全为空或全为0，请检查！", SQ_type: "error"});
                            return false; //验证不通过，不执行以下代码
                        }
                        var check1 = gps1 && gps2 && gps1 == gps2 && (gps1 != 0 && gps2 != 0);
                        var check2 = gps1 && gps3 && gps1 == gps3 && (gps1 != 0 && gps3 != 0);
                        var check3 = gps2 && gps3 && gps2 == gps3 && (gps2 != 0 && gps3 != 0);
                        if (check1 || check2 || check3) {
                            top.$.ligerDialog.SQalert({content: "有重复GPS卡号，请检查！", SQ_type: "error"});
                            return false; //验证不通过，不执行以下代码
                        }
                        if (!validateGPS(gps1)) {
                            return false;
                        }
                        if (!validateGPS(gps2)) {
                            return false;
                        }
                        if (!validateGPS(gps3)) {
                            return false;
                        }
                        // 校验安装人
                        var installer = $("#installer").val();
                        if ("" == installer || null == installer) {
                            top.$.ligerDialog.SQalert({content: "请填写安装人！", SQ_type: "error"});
                            return false; //验证不通过，不执行以下代码
                        }
                        // 校验安装时间
                        var installDt = $("#installDt").val();
                        if ("" == installDt || null == installDt) {
                            top.$.ligerDialog.SQalert({content: "请填写安装时间！", SQ_type: "error"});
                            return false; //验证不通过，不执行以下代码
                        }
                    }
                }
            }

			var ligerForm = liger.get("redeemCar_view");
			if (!ligerForm.valid()) {
				top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "error"});
				return false; //验证不通过，不执行以下代码
			}
			//获取赎回主表ID
			var redeemId = $("#redeem_Id").val();
			//获取处置收款表ID
			var assDealRecAmtId = $("#assDealRecAmt_id").val();
			//获取表单数据
			var data = ligerForm.getData();
			data["depositBaseAmt"] = $("#depositBaseAmt").val();
			// console.log(data);
			//修改赎回信息主表数据
			var wait_dialog = null;
			var url = '';
			if(opFlag == "1" || opFlag == "4"){//发起人-财务确认到账-提车人
				url = '<%=path%>/ass/assTrailCarD/modifyRedeemInfo.do';
				if(!redeemId){//为空提示
					top.$.ligerDialog.SQalert({content: "赎回主表ID为空,无法保存！",SQ_type: "error"});
					return false;
				}
			}else if(opFlag == "3"){//通知打款-处置收款信息
				data["dataId"] = redeemId;
				data["dataTypeCd"] = "2";//赎回
				url = '<%=path%>/ass/assTrailCarD/updateYCDealInfo.do';
			}else{
				$.ligerDialog.SQalert({content: "操作码无法识别,不能保存！",SQ_type: "error"});
				return false;
			}
			$.ajax({
				type: 'post',
				dataType: 'json',
				data: data,
				url: url,
				beforeSend: function(){
					wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
				},
				success:function(msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        if ("1" == redeemTypCd && ("2" == flag || "6" == flag)) {
                            $("#cstStlIrr").html(msg.data.cstStlIrr * 100);
                            $("#redeemStlDiscountAmt1").html(msg.data.discountAmt);
                            var receivableAmt = $("#redeemAmt").val() - msg.data.discountAmt;
                            $("#receivableAmt").val(receivableAmt);
                        }
                        saveFile("");//保存文件
                        //设置处置收款表ID值
                        if (!assDealRecAmtId && msg.data) {
                            $("#assDealRecAmt_id").val(msg.data);
                        }
                        // 商助审核GPS节点且是赎回转正常时，新增GPS
                        if ("11" == flag && "2" == redeemTypCd) {
                            addGps(msg, data);
                        }
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                    } else if (msg.success == 2) {
                        // 商助审核GPS节点且是赎回转正常时，新增GPS
                        if ("11" == flag && "2" == redeemTypCd) {
                            $.ligerDialog.confirm(msg.info, function (flag) {
                                if (flag == false) return;
                                addGps(msg, data);
                                saveFile("");//保存文件
                                //设置处置收款表ID值
                                if (!assDealRecAmtId && msg.data) {
                                    $("#assDealRecAmt_id").val(msg.data);
                                }
                            });
                        }
                    } else {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
			});
		}

		//取消/关闭当前页签
		function closeBtn(){
			var TAB=top.mainApp.parentTab;
			var currentTabid=TAB.getSelectedTabItemID();
			top.tab.removeTabItem(currentTabid);
		}
		
		//计算赎回金额
		function planRedeemMoney(){
			var flag = $("#flag").val();//节点标识
			var redeemTypeCd = $("#redeemTypeCd").val();//赎回方式
			var value1 = $("#depositAmt").val();//赎回保证金
			var value2 = $("#overdueAmt").val();//赎回逾期租金
			var value3 = $("#interestAmt").val();//赎回罚息
			var value4 = $("#actPayBackAmt").val();//实际付款金额(实际支付拖车费用)
			var value5 = $("#actOverdueAmt").val();//实际赎回逾期租金
			var value6 = $("#actInterestAmt").val();//实际赎回罚息
			if(value4 == '' || value4==undefined){
				value4=0;
			}
			if(value1=='' || value1==undefined){
				value1=0;
			}
			//财务确认到账-计算实际赎回信息
			if(flag=="6" && redeemTypeCd == "2"){
				value2 = value5;
				value3 = value6;
			}
			//开始计算赎回金额
			var redeemMoney = 0;
			if(value1!='' && value2!='' && value3!=''){
				redeemMoney = parseFloat(value1)+parseFloat(value2)+parseFloat(value3)+parseFloat(value4);
			}else if(value1!='' && value2!=''){
				redeemMoney = parseFloat(value1)+parseFloat(value2)+parseFloat(value4);
			}else if(value2!='' && value3!=''){
				redeemMoney = parseFloat(value2)+parseFloat(value3)+parseFloat(value4);
			}else if(value1!='' && value3!=''){
				redeemMoney = parseFloat(value1)+parseFloat(value3)+parseFloat(value4);
			}else if(value1!=''){
				redeemMoney = parseFloat(value1)+parseFloat(value4);
			}else if(value2!=''){
				redeemMoney = parseFloat(value2)+parseFloat(value4);
			}else if(value3!=''){
				redeemMoney = parseFloat(value3)+parseFloat(value4);
			}
			if(flag=="2"){//财务核算
				$("#redeemAmt").val(anyString(redeemMoney,2));//保留2位
			}else if(flag=="6" && redeemTypeCd == "2"){//财务确认到账
				$("#actRedeemAmt").val(anyString(redeemMoney,2));//保留2位
			}
		}
		
		//根据所选获取是合同额还是融资额
		function getTopric(typeId){
			var type = $("#"+typeId).val();
			if(type=="2"){
				return $("#actLsAmt").val();
			}else{
				return $("#contAmt").val();
			}
		}
		
		//计算赎回保证金
		function planRedeemMargin(){
			var topric = getTopric('amtTypeCd');
			var redeemMarginPercent = $("#depositPct").val();
			if (redeemMarginPercent.length > 0) {
				//不执行操作
			}else{
				$.ligerDialog.SQalert({content: "赎回保证金比例不能为空！",SQ_type: "warning"});
				return false;
			}
			if (isNumber(redeemMarginPercent) || isDouble(redeemMarginPercent)) {
				$("#depositAmt").val(redeemMarginPercent * topric / 100);
				planRedeemMoney();
			} else {
				$.ligerDialog.SQalert({content: "你输入的手续费比例不正确！",SQ_type: "warning"});
				$("#depositPct").val('');
				$("#depositAmt").val('');
				return false;
			}
		}
		
		//计算赎回保证金比例
		function planRedeemMarginPercent(){
			var topric = getTopric('amtTypeCd');
			var redeemMargin = $("#depositAmt").val();
			if (redeemMargin.length > 0) {
				//不执行操作
			}else{
				$.ligerDialog.SQalert({content: "赎回保证金不能为空！",SQ_type: "warning"});
				return false;
			}
			if (isNumber(redeemMargin) || isDouble(redeemMargin)) {
				$("#depositPct").val(redeemMargin / topric * 100);
				planRedeemMoney();
			} else {
				$.ligerDialog.SQalert({content: "你输入的手续费比例不正确！",SQ_type: "warning"});
				$("#depositPct").val('');
				$("#depositAmt").val('');
				return false;
			}
		}
		
		//设置显示/编辑属性
		function showOrEdit(){
	    	var flag = $("#flag").val();
	    	var buOrgCd = $("#buOrgCd").val();
	    	var redeemTypeCd = $("#redeemTypeCd").val();//赎回方式

            if ("2" == redeemTypeCd) {
                // 赎回转正常时(展示对客结清IRR和结清优惠金额1)
                $("#redeemCar_view").find(".show_irr").each(function (){
                    $(this).addClass('Hide');
                });
                $("#redeemCar_view").find(".show_stl_discount_amt_1").each(function (){
                    $(this).addClass('Hide');
                });
            }
			//赎回申请基础信息
			if(flag == "1"){//可编辑-发起人
				$("#redeemCar_view").find(".edit_fqr").each(function (){
					$(this).removeClass('Hide');
	        	});
				$("#redeemCar_view").find(".show_fqr").each(function (){
					$(this).addClass('Hide');
	        	});
			}else{//不可编辑
				$("#redeemCar_view").find(".edit_fqr").each(function (){
					$(this).addClass('Hide');
	        	});
				$("#redeemCar_view").find(".show_fqr").each(function (){
					$(this).removeClass('Hide');
	        	});
				liger.get("redeemTypeCd").setDisabled(true);//赎回方式
				if(flag != "11"){
					liger.get("isOnline").setDisabled(true);//GPS是否在线
				}
			}
			//赎回金额等信息
			if(flag == "2" || (buOrgCd == "00000005" && flag == "1")){//可编辑-财务核算赎回金额/乘用车发起人
				$("#redeemCar_view").find(".edit_cwhs").each(function (){
					$(this).removeClass('Hide');
	        	});
				$("#redeemCar_view").find(".show_cwhs").each(function (){
					$(this).addClass('Hide');
	        	});
			}else{
				$("#redeemCar_view").find(".edit_cwhs").each(function (){
					$(this).addClass('Hide');
	        	});
				$("#redeemCar_view").find(".show_cwhs").each(function (){
					$(this).removeClass('Hide');
	        	});
			}
			//赎回转正常："风险保证金1"修改授权"财务确认到账"节点更改
			if(((flag == "2" || (buOrgCd == "00000005" && flag == "1")) && redeemTypeCd == "1") //赎回结清-可编辑-财务核算赎回金额/乘用车发起人
				|| (flag == "6" && redeemTypeCd == "2")){//赎回转正常-可编辑-财务确认到账
				$("#redeemCar_view").find(".edit_fxbzj").each(function (){
					$(this).removeClass('Hide');
	        	});
				$("#redeemCar_view").find(".show_fxbzj").each(function (){
					$(this).addClass('Hide');
	        	});
			}else{
				$("#redeemCar_view").find(".edit_fxbzj").each(function (){
					$(this).addClass('Hide');
	        	});
				$("#redeemCar_view").find(".show_fxbzj").each(function (){
					$(this).removeClass('Hide');
	        	});
			}
			
			//赎回说明编辑状态
			if(flag == "1" || flag == "2"){//可编辑
				$(".edit_shsm").removeClass('Hide');
				$(".show_shsm").addClass('Hide');
			}else{//不可编辑
				$(".edit_shsm").addClass('Hide');
				$(".show_shsm").removeClass('Hide');
			}
			//保存申请信息按钮和赎回附件
			if(flag == "1" || flag == "2" || "6" == flag || flag == "11"){
				$(".edit_shfj").removeClass('Hide');
				$(".edit_bsxx").removeClass('Hide');
			}else{
				$(".edit_shfj").addClass('Hide');
				$(".edit_bsxx").addClass('Hide');
			}
			//付款和收款信息
			if(flag == "5"){//可编辑-通知打款
				$("#redeemCar_view").find(".edit_tzdk").each(function (){
					$(this).removeClass('Hide');
	        	});
				$("#redeemCar_view").find(".show_tzdk").each(function (){
					$(this).addClass('Hide');
	        	});
			}else{
				$("#redeemCar_view").find(".edit_tzdk").each(function (){
					$(this).addClass('Hide');
	        	});
				$("#redeemCar_view").find(".show_tzdk").each(function (){
					$(this).removeClass('Hide');
	        	});
			}
			//保存应收和到账按钮
			if(flag == "2" || flag == "6"){
				$(".edit_ysdz").removeClass('Hide');
				if ('1' == redeemTypeCd) {
				    // 赎回结清(展示对客结清IRR)
                    $(".show_irr").removeClass('Hide');
                }
			}else{
				$(".edit_ysdz").addClass('Hide');
                $(".show_irr").addClass('Hide');
			}
			//实际到账信息
			if(flag == "6"){//可编辑-财务确认到账
				$("#redeemCar_view").find(".edit_cwqr").each(function (){
					$(this).removeClass('Hide');
	        	});
				$("#redeemCar_view").find(".show_cwqr").each(function (){
					$(this).addClass('Hide');
	        	});
			}else{
				$("#redeemCar_view").find(".edit_cwqr").each(function (){
					$(this).addClass('Hide');
	        	});
				$("#redeemCar_view").find(".show_cwqr").each(function (){
					$(this).removeClass('Hide');
	        	});
			}
			//提车人信息
			if(flag == "5" || flag == "7"){//可编辑-通知打款/补充提车信息
				$("#redeemCar_view").find(".edit_tcr").each(function (){
					$(this).removeClass('Hide');
	        	});
				$("#redeemCar_view").find(".show_tcr").each(function (){
					$(this).addClass('Hide');
	        	});
				$(".saveBtn").removeClass('Hide');
			}else{
				$("#redeemCar_view").find(".edit_tcr").each(function (){
					$(this).addClass('Hide');
	        	});
				$("#redeemCar_view").find(".show_tcr").each(function (){
					$(this).removeClass('Hide');
	        	});
				$(".saveBtn").addClass('Hide');
			}

			// gps是否在线
			var isGpsOnline = $("#isOnline").val();
			// 商助审核GPS隐藏提车人上传附件按钮
			if ("11" == flag) {
                $(".tcr_file").addClass('Hide');
                // 赎回转正常
                if ('2' == redeemTypeCd) {
                    // 当gps是否在线不为空时
                    if (null != isGpsOnline && "" != isGpsOnline) {
                    $(".carNo").removeClass('Hide');
                    $(".vin").removeClass('Hide');
                    $(".gps1").removeClass('Hide');
                    $(".gps2").removeClass('Hide');
                    $(".gps3").removeClass('Hide');
                    $(".gpsTitle").removeClass('Hide');
                    liger.get("carNo").setDisabled();
                    liger.get("vin").setDisabled();
                    if ("1" == isGpsOnline) {
                        // gps在线（是）
                        liger.get("gps1").setDisabled();
                        liger.get("gps2").setDisabled();
                        liger.get("gps3").setDisabled();
                        $(".gpsRem").addClass('Hide');
                        $(".showGpsFiles").addClass('Hide');
                        $(".edit_shfj_gps").addClass('Hide');
                        $(".installer").addClass('Hide');
                        $(".installDt").addClass('Hide');
                    } else if ("0" == isGpsOnline) {
                        // gps不在线（否）
                        $(".installer").removeClass('Hide');
                        $(".installDt").removeClass('Hide');
                        $(".gpsRem").removeClass('Hide');
                        $(".showGpsFiles").removeClass('Hide');
                        $(".edit_shfj_gps").removeClass('Hide');
                        liger.get("gps1").setEnabled();
                        liger.get("gps2").setEnabled();
                        liger.get("gps3").setEnabled();
                    }
                }
            }
            }
			// 分别是：呈报人补充提车人信息；资产管理员出库登记；系统管理员核查出库；财务做账
            if ("7" == flag || "8" == flag || "9" == flag || "12" == flag) {
                $(".tcr_file").addClass('Hide');
                // 赎回转正常
                if ('2' == redeemTypeCd) {
                    $(".carNo").removeClass('Hide');
                    $(".vin").removeClass('Hide');
                    $(".gps1").removeClass('Hide');
                    $(".gps2").removeClass('Hide');
                    $(".gps3").removeClass('Hide');
                    $(".gpsTitle").removeClass('Hide');
                    liger.get("carNo").setDisabled();
                    liger.get("vin").setDisabled();
                    if ("1" == isGpsOnline) {
                        // gps在线（是）
                        liger.get("gps1").setDisabled();
                        liger.get("gps2").setDisabled();
                        liger.get("gps3").setDisabled();
                        $(".gpsRem").addClass('Hide');
                        $(".showGpsFiles").addClass('Hide');
                        $(".edit_shfj_gps").addClass('Hide');
                    } else if ("0" == isGpsOnline) {
                        // gps不在线（否）
                        $(".installer").removeClass('Hide');
                        $(".installDt").removeClass('Hide');
                        $(".gpsRem").removeClass('Hide');
                        $(".showGpsFiles").removeClass('Hide');
                        liger.get("gps1").setDisabled();
                        liger.get("gps2").setDisabled();
                        liger.get("gps3").setDisabled();
                    }
                    liger.get("installer").setDisabled();
                    liger.get("installDt").setDisabled();
                    liger.get("gpsRem").setDisabled();
                }
            }
			//是否隐藏：实际到账金额、实际到账时间
			if (isDetail && isDetail == '0') {
				$("#redeemCar_view").find(".hide_abc").each(function (){
					$(this).addClass('Hide');
				});
			}

		}
		
		//初始化付款信息
		var grid = $("#ligergrid2").ligerGrid({
            url: '<%=path%>/ass/assTrailCarM/getAssDealRecAmtList.do?flag=1&dataTypeCd=2&dataId='+$("#redeem_Id").val(),
            method: 'get',
            columns: [
                {display: '银行信息', name: 'payerBankNm', minWidth: 120, align: 'center', enabledSort: false},
                {display: '账号信息', name: 'payerAccNo', minWidth: 100, align: 'center', enabledSort: false},
                {display: '付款方名称', name: 'payerAccNm', minWidth: 120, align: 'center', enabledSort: false},
                {display: '付款金额(元)', name: 'payAmt', width: 100, align: 'center', enabledSort: false,
					render: function (rowdata, rowindex, value, column) { 
						var h = rowdata.payAmt / 100;
						return h;
					}},
				{display: '使用金额(元)', name: 'useAmt', width: 100, align: 'center', enabledSort: false,
					render: function (rowdata, rowindex, value, column) {
						var h = rowdata.useAmt / 100;
						return h;
					}},
				{display: '付款时间', name: 'payTm', width: 100, align:'center', enabledSort:true,
					render: function (rowdata, rowindex, value, column) { 
						var h = renderDate1(rowdata.payTm);
						return h;
					}},
				{display: '到账时间', name: 'receivedTm', width: 100, align:'center', enabledSort:true,
					render: function (rowdata, rowindex, value, column) { 
						var h = renderDate1(rowdata.receivedTm);
						return h;
					}},
                {display: '到账金额(元)', name: 'receivedAmt', width: 100, align: 'center', enabledSort: false,
					render: function (rowdata, rowindex, value, column) { 
						var h = rowdata.receivedAmt / 100;
						return h;
					}},
                {display: '操作', name: '', width: 150, align: 'center', enabledSort: false,
                    render:function(rowdata,rowindex,value){
                    	var h='';
                        if('${flag}' == '5' || '${flag}' == '6'){//发起人/财务
							h+='<a class="sq-button-hasicon ' + l_hidden + '" style="cursor:pointer;" href="javascript:editPayInfo(';
                            h+="'"+rowdata.id+"'";
                            h+=')"><i class="sqBtnIco_4"></i>修改</a>';
                            if('${flag}' == '5'){//发起人通知打款
								h+='<a class="sq-button-hasicon" style="cursor:pointer;" href="javascript:deletePayInfo(';
								h+="'"+rowdata.id+"'";
								h+=')"><i class="sqBtnIco_7"></i>删除</a>';
                            }else{
								h+='<font class="sq-button-hasicon" color="c9c9c9"><i class="sqBtnIco_7"></i>删除</font>';
                            }
                        }else{
                        	h+='<font class="sq-button-hasicon" color="c9c9c9"><i class="sqBtnIco_4"></i>修改</font>';
                        	h+='<font class="sq-button-hasicon" color="c9c9c9"><i class="sqBtnIco_7"></i>删除</font>';
                        }
                        return h;
                    }
                },
            ],
            //pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            heightDiff: -2,
            checkbox: true,
	        usePager: false,//是否分页
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: true,
            onSelectRow: function (rowdata,rowNum,rowEl) {
                $.extend(true, pageInApp, {seletedCompRow: rowdata});
            },
            onUnSelectRow: function (rowdata) {
                $.extend(true, pageInApp, {seletedCompRow: null});
            }
        });
        //添加付款信息
        function editPayInfo(id){
        	var param = id+"&dataId="+$("#redeem_Id").val()+"&flag="+$("#flag").val()+"&goFlag=1";
			$.ligerDialog.open({
                width:800,
                height: 260,
                title: '编辑付款信息',
                url: '<%=path%>/ass/assTrailCarD/toRecAmtPage.do?assDealRecAmt_id='+param
			});
		}
      	//删除付款信息
   	    function deletePayInfo(id){
	   	    $.ligerDialog.confirm("是否确认删除选中的付款信息数据?", function (flag) {
	            if (flag == false)return;
	            var wait_dialog = null;
	            $.ajax({
	                type: 'post',
	                dataType: 'json',
	                data: {id: id},
	                url: '<%=path%>/ass/assTrailCarD/deleteRecAmt.do',
	                beforeSend: function () {
	                    wait_dialog = $.ligerDialog.SQalert({
	                        content: LogUtils.LOG_CMM_DATA_LOADING,
	                        SQ_type: "waitting"
	                    });
	                },
	                success: function (msg) {
	                    wait_dialog.close();
	                    if (msg.success == 1) {
	                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
	                        grid.reload();
	                    } else {
	                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
	                    }
	                }
	            });
	        });
		}
      	
      	
		// kfc add 170908
   		//初始化核销列表信息
		var grid = $("#ligergrid3").ligerGrid({
            url: '<%=path%>/ass/assTrailCarD/searchCapFundVerificationList.do?redeem_Id='+$("#redeem_Id").val()+'&paySchId='+$("#paySchId").val()+'&tcDetailId='+$("#tcDetailId").val(),
            method: 'get',
            columns: [
                      {display: '分解单号', name: 'vfNo', minWidth: 60, align: 'left', enabledSort: false,
                          render:function(rowdata,index,value){
                              return "<a onclick='qyFundDecom("+rowdata.fundId+","+rowdata.id+")'>"+rowdata.vfNo+"</a>";
                          }
                      },
                      {display: '来款金额', name: 'vfAmt', width: 360, align: 'left', enabledSort: false,
                          render:function(rowdata,index,value){
                              return FormatMoney(rowdata.vfAmt/100);
                          }
                      },
                     /* {display: '操作', minWidth: 100, align: 'center', enabledSort: false,
                          render:function(rowdata,index,value){
                        	  if(rowdata.vfStsCd != "5"){
                        		  return "<a style='cursor: pointer;' onclick='revertFund("+rowdata.id+")'>申请冲红</a>";
                        	  }
                          }
                      },*/
                  ],
            //pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            heightDiff: -2,
            checkbox: true,
	        usePager: false,//是否分页
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: true,
            onSelectRow: function (rowdata,rowNum,rowEl) {
                $.extend(true, pageInApp, {seletedCompRow: rowdata});
            },
            onUnSelectRow: function (rowdata) {
                $.extend(true, pageInApp, {seletedCompRow: null});
            }
        });
     
		//冲红
	    function revertFund(){
	    	var grid = liger.get("ligergrid3");
			var selectedRows = grid.getSelectedRows();
			if(selectedRows.length == 0){
				$.ligerDialog.SQalert({content: "请选择冲红数据",SQ_type: "warning"});
				return false;
			}
			var vfIds = new Array();
			for(var i=0;i<selectedRows.length;i++){
				vfIds[i] = selectedRows[i].id;
			}
	        var vfIds2 = JSON.stringify(vfIds);
			$.ligerDialog.open({
                width:800,
                height: 260,
                title: '申请冲红',
                url: '<%=path%>/ass/assTrailCarD/toRevertFundPage.do?vfIds='+vfIds2+"&redeem_Id="+$("#redeem_Id").val()+"&tcDetailId="+$("#tcDetailId").val()+"&flag="+$("#flag").val()
			});
	    }

    </script>
</body>
</html>